package com.xzkydz.sensor.utils;

import java.util.Random;

/**
 * @Description: 随机数管理
 */
public class RandomUtils {
    private Random myRandom;

    private RandomUtils() {
        myRandom = new Random();
    }

    /**
     * 获取随机数 int
     *
     * @param baseValue 基值 最小值
     * @param bound     随机范围
     * @return
     */
    public int randomInt(int baseValue, int bound) {
        return baseValue + myRandom.nextInt(bound);
    }

    /**
     * 获取随机数 float
     *
     * @param baseValue 基值 最小值
     * @return
     */
    public float randomFloat(float baseValue) {
        return baseValue * myRandom.nextFloat();
    }

    private static class SingletonInstance {
        private static final RandomUtils INSTANCE = new RandomUtils();
    }

    public static RandomUtils getInstance() {
        return SingletonInstance.INSTANCE;
    }
}